#pragma once

#include <py32f002b_hal_def.h>
#include <py32f002b_hal_i2c.h>

#include "i2c_slave.h"

extern I2C_HandleTypeDef I2c1Handle;

#define MAX_REG_DATA_SIZE 4

struct I2CSlaveDummyRegister {
    uint8_t addr;
    uint8_t data[MAX_REG_DATA_SIZE]; //4字节data
    uint8_t isReadOnly;

    volatile uint8_t isUpdate;
};

struct I2CSlaveInitParam {
    uint32_t gpioPin;
    GPIO_TypeDef *gpioPort;
    uint32_t freq;
    uint32_t address;
};

int32_t I2C1_SlaveInit(const struct I2CSlaveInitParam *paramm,
                    struct I2CSlaveDummyRegister *dummyReg,
                    uint8_t dummyRegSize);

void I2C1_SlaveDeinit();